package com.hg.miaosha.dto;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.plugins.Page;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * created by skh on 2019/6/15
 */
@Data
public class PageDTO {

	@ApiModelProperty("第几页")
	private Integer pageNo;

	@ApiModelProperty("每页数量")
	private Integer pageLimit;

	@ApiModelProperty("排序字段")
	private String orderByField;

	@ApiModelProperty("是否升序")
	private Boolean isAsc;

	public Page pageInit(PageDTO pageDTO) {
		Page page = new Page<>(pageDTO.getPageNo(), pageDTO.getPageLimit());

		if (StrUtil.isNotBlank(orderByField) && isAsc != null) {
			page.setOrderByField(orderByField);
			page.setAsc(isAsc);
		}

		return page;
	}
}
